<template>
  <div>
      <el-table :data="companyList" style="width: 100%;">
          <el-table-column fixed prop="sponsorName" label="公司名称" width="400" />
          <el-table-column prop="sponsorAddress" label="公司地址" width="400" />
          <el-table-column prop="personalBalance" label="个人账户余额" width="200" />
          <el-table-column prop="overallBalance" label="公司账户余额" width="200" />
          <el-table-column fixed="right" label="操作" width="150">
            <template #default=scope>
              <el-button link type="primary" size="small" @click="handleClick(scope)"
                >缴纳</el-button
              >
          <!-- <el-button link type="primary" size="small">Edit</el-button> -->
           </template>
          </el-table-column>
      </el-table>
  </div>
</template>

<script setup>
import myAxios from "../../plugins/myAxios.js"
import { onMounted } from 'vue';
import { ref } from 'vue';
import { ElNotification } from 'element-plus'

//公司列表
const companyList = ref([]);

const handleClick = () => {
  ElNotification({
    title: '错误',
    message: '目前管理员不能给公司充值',
    type: 'warning',
  })
}

// 查询公司列表
const query = () => {
console.log(localStorage.getItem('senderAddress'))
myAxios.post("/query/companys", {userAddress: localStorage.getItem('senderAddress')})
.then((res) => {
  if (res.data.code === 200) {
    companyList.value = res.data.data;
    // cookies.set('companyList', JSON.stringify(companyList.value))
  } else {
    alert(`请求失败：${res.data.msg}`);
  }
})
.catch((error) => {
    alert(`请求失败：${error}`);
  });
}

onMounted(() => {
query()
})
</script>
